<template>
  <el-switch
    style="display: block"
    v-model="scope.row[column.prop]"
    :active-text="''"
    :inactive-text="column.text2"
    :active-value="active[1]"
    :inactive-value="active[0]"
    @change="onSwitch(scope.row)"
    v-bind="column.props"
  >
  </el-switch>
</template>

<script>
  export default {
    name:'ColumnSwitch',
    props:{
      scope:Object,
      column:{
        type:Object
      }
    },
    data(){
      return {
        active:[]
      }
    },
    created(){
      this.active = this.column.active || [0,1];
    },
    methods:{
      onSwitch(row){
        const onChange = this.column.onChange;
        onChange && onChange(row);
      }
    }
  }
</script>
